# In R: load the output from the shrna_matrixgen.pl and the training matrix
# then train the e1071 svm and predict 
# if not installed:
install.packages("e1071") 

library(e1071)
train50_FT <- read.table("train50_FT.txt", header=TRUE, sep="\t", row.names="ID", stringsAsFactors=FALSE)
names(train50_FT)
# should be linear kernel- radial kernel does not provide good discrimination
#t50_FT_tune <- tune.svm(Score ~ ., data=train50_FT, type="eps-regression", kernel="linear", cost=seq(2,4,len=3), gamma=seq(5,7,len=3), tunecontrol=tune.control(cross=5))
#t50_FT_tune
t50_FT_svm <- svm(Score ~ ., data=train50_FT, type="eps-regression", kernel="linear", cost=2.25, gamma=0.1)

#replace gene with gene name...
GENE_test <- read.table("GENE_out.txt", header=TRUE, sep="\t", row.names="ID", stringsAsFactors=FALSE)
GENE_predict <- predict(t50_FT_svm,GENE_test)
write.table(GENE_predict,file="GENE_predict")

